package com.pb.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

//@WebFilter(urlPatterns = "/*")
@Slf4j
public class DemoFilter implements Filter {
    //初始一次
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("初始化----------");
    }

    //过滤器
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("拦截到");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);
    }

    //销毁一次
    @Override
    public void destroy() {
        log.info("销毁了-----------");
    }
}
